<template>
  <div>
    <!-- 搜索 -->
    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable height="auto" selectionType="single" ref="table" :columns="columns" :params="fetchParams" :fetchapi="fetchapi" :dataSource="dataList" :datakey="'records'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange"> </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      <multiuse-button type="primary" :click="saveDialog.bind()">确 定</multiuse-button>
    </div>
  </div>
</template>
<script>
import {  getModelList } from '@/api/dictionary/index';
export default {
  data() {
    return {
      dataList: [],
      visible: false,
      collapse: false,
      topFilterInit: this.topFilterInitFun(),
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      fetchapi :getModelList
    };
  },
  created() {
  },
  methods: {
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      if (this.selectedRows.length > 0) {
        this.$emit('save', this.selectedRows);
      }
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    },
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '品牌', fieldName: 'claimNo', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '车型', fieldName: 'no', placeholder: '请输入', initialValue: '' }
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({}, this.fetchParams, val);
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        // {
        //   title: '操作',
        //   dataIndex: 'column-action',
        //   width: 100,
        //   fixed: 'left',
        //   render: props => {
        //     return (
        //       <div style="text-align:center">
        //         <multiuse-button type="primary" icon="el-icon-edit" circle></multiuse-button>
        //         <multiuse-button type="primary" icon="el-icon-delete" circle></multiuse-button>
        //       </div>
        //     );
        //   }
        // },
        { title: '品牌', dataIndex: 'modelName', sorter: true },
        { title: '车型', dataIndex: 'modelCode', sorter: true }

        // ,
        // { title: '员工代码', dataIndex: 'employeeNo', sorter: true },
        // { title: '员工姓名', dataIndex: 'employeeName', sorter: true },
        // {
        //   title: '性别',
        //   dataIndex: 'gender',
        //   sorter: true,
        //   render: props => {
        //     return <span>{this.createDictText(props.row.gender, '1056')}</span>;
        //   }
        // },
        // { title: '手机', dataIndex: 'phone', sorter: true },
        // { title: '身份证号码', dataIndex: 'certificateId', sorter: true }
      ];
    }
  }
};
</script>

<style lang="less" scoped></style>
